-- Copyright (c) Huawei Technologies Co., Ltd. 2025. All rights reserved.
--
-- this file licensed under the Mulan PSL v2.
-- You can use this software according to the terms and conditions of the Mulan PSL v2.
-- You may obtain a copy of Mulan PSL v2 at: http://license.coscl.org.cn/MulanPSL2
--
-- THIS SOFTWARE IS PROVIDED ON AN "AS IS" BASIS, WITHOUT WARRANTIES OF ANY KIND, EITHER EXPRESS OR
-- IMPLIED, INCLUDING BUT NOT LIMITED TO NON-INFRINGEMENT, MERCHANTABILITY OR FIT FOR A PARTICULAR
-- PURPOSE.
-- See the Mulan PSL v2 for more details.
--
-- Author: auto generate
-- Create: 2025-10-19
-- Description: DO NOT EDIT; Code generated by "message.lua.mako"
local validate = require 'mc.validate'
local utils = require 'mc.utils'

local MCANMgmt = {}

---@class MCANMgmt.Enabled
---@field Enabled boolean
local TEnabled = {}
TEnabled.__index = TEnabled
TEnabled.group = {}

local function TEnabled_from_obj(obj)
    return setmetatable(obj, TEnabled)
end

function TEnabled.new(Enabled)
    return TEnabled_from_obj({Enabled = Enabled or false})
end
---@param obj MCANMgmt.Enabled
function TEnabled:init_from_obj(obj)
    self.Enabled = obj.Enabled or false
end

function TEnabled:remove_error_props(errs, obj)
    utils.remove_obj_error_property(obj, errs, TEnabled.group)
end

TEnabled.from_obj = TEnabled_from_obj

TEnabled.proto_property = {'Enabled'}

TEnabled.default = {false}

TEnabled.struct = {{name = 'Enabled', is_array = false, struct = nil}}

function TEnabled:validate(prefix, errs, need_convert)
    prefix = prefix or ''

    validate.Optional(prefix .. 'Enabled', self.Enabled, 'bool', false, errs, need_convert)

    TEnabled:remove_error_props(errs, self)
    validate.CheckUnknowProperty(self, TEnabled.proto_property, errs, need_convert)
    return self
end

function TEnabled:unpack(_)
    return self.Enabled
end

MCANMgmt.Enabled = TEnabled

---@class MCANMgmt.Channels
---@field Channels integer[]
local TChannels = {}
TChannels.__index = TChannels
TChannels.group = {}

local function TChannels_from_obj(obj)
    return setmetatable(obj, TChannels)
end

function TChannels.new(Channels)
    return TChannels_from_obj({Channels = Channels})
end
---@param obj MCANMgmt.Channels
function TChannels:init_from_obj(obj)
    self.Channels = obj.Channels
end

function TChannels:remove_error_props(errs, obj)
    utils.remove_obj_error_property(obj, errs, TChannels.group)
end

TChannels.from_obj = TChannels_from_obj

TChannels.proto_property = {'Channels'}

TChannels.default = {{}}

TChannels.struct = {{name = 'Channels', is_array = true, struct = nil}}

function TChannels:validate(prefix, errs, need_convert)
    prefix = prefix or ''

    validate.OptionalArray(prefix .. 'Channels', self.Channels, 'uint8', false, errs, need_convert)

    TChannels:remove_error_props(errs, self)
    validate.CheckUnknowProperty(self, TChannels.proto_property, errs, need_convert)
    return self
end

function TChannels:unpack(_)
    return self.Channels
end

MCANMgmt.Channels = TChannels

---@class MCANMgmt.Identifier
---@field Identifier integer
local TIdentifier = {}
TIdentifier.__index = TIdentifier
TIdentifier.group = {}

local function TIdentifier_from_obj(obj)
    return setmetatable(obj, TIdentifier)
end

function TIdentifier.new(Identifier)
    return TIdentifier_from_obj({Identifier = Identifier or 255})
end
---@param obj MCANMgmt.Identifier
function TIdentifier:init_from_obj(obj)
    self.Identifier = obj.Identifier or 255
end

function TIdentifier:remove_error_props(errs, obj)
    utils.remove_obj_error_property(obj, errs, TIdentifier.group)
end

TIdentifier.from_obj = TIdentifier_from_obj

TIdentifier.proto_property = {'Identifier'}

TIdentifier.default = {0}

TIdentifier.struct = {{name = 'Identifier', is_array = false, struct = nil}}

function TIdentifier:validate(prefix, errs, need_convert)
    prefix = prefix or ''

    validate.Optional(prefix .. 'Identifier', self.Identifier, 'uint8', false, errs, need_convert)

    TIdentifier:remove_error_props(errs, self)
    validate.CheckUnknowProperty(self, TIdentifier.proto_property, errs, need_convert)
    return self
end

function TIdentifier:unpack(_)
    return self.Identifier
end

MCANMgmt.Identifier = TIdentifier

return MCANMgmt
